<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class SystemRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required',
            'key' => 'required|regex:/^[a-zA-_Z]+$/',
        ];
    }
    
    public function messages() {
        return [
            'title.required' => '配置项名称不能为空',
            'key.required' => '变量名不能为空',
            'key.regex' => '变量名只能为英文字母和下划线',
        ];
    }
}
